package com.jthinker.blog.web.controller.admin.index;

import com.alibaba.fastjson.JSON;
import com.jthinker.blog.bean.entity.Menu;
import com.jthinker.blog.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * User: Gang Chen
 * Date: 2015/6/27 21:55
 */
@Controller
public class AdminIndexController
{
    @Autowired
    private MenuService menuService;

    @RequestMapping({ "/index", "/", "" })
    public ModelAndView view()
    {
        ModelAndView mv = new ModelAndView("index/adminIndex");
        List<Menu> menus = menuService.listAllBySort();

        mv.addObject("menus", JSON.toJSONString(menus));
        return mv;
    }
}
